package com.new_wear.project.activity.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.new_wear.project.activity.mapper.CstActivityMapper;
import com.new_wear.project.activity.domain.CstActivity;
import com.new_wear.project.activity.service.ICstActivityService;
import com.new_wear.common.utils.text.Convert;

/**
 * 活动Service业务层处理
 * 
 * @author new_wear
 * @date 2020-01-07
 */
@Service
public class CstActivityServiceImpl implements ICstActivityService 
{
    @Autowired
    private CstActivityMapper cstActivityMapper;

    /**
     * 查询活动
     * 
     * @param id 活动ID
     * @return 活动
     */
    @Override
    public CstActivity selectCstActivityById(Integer id)
    {
        return cstActivityMapper.selectCstActivityById(id);
    }

    /**
     * 查询活动列表
     * 
     * @param cstActivity 活动
     * @return 活动
     */
    @Override
    public List<CstActivity> selectCstActivityList(CstActivity cstActivity)
    {
        return cstActivityMapper.selectCstActivityList(cstActivity);
    }

    /**
     * 新增活动
     * 
     * @param cstActivity 活动
     * @return 结果
     */
    @Override
    public int insertCstActivity(CstActivity cstActivity)
    {
        return cstActivityMapper.insertCstActivity(cstActivity);
    }

    /**
     * 修改活动
     * 
     * @param cstActivity 活动
     * @return 结果
     */
    @Override
    public int updateCstActivity(CstActivity cstActivity)
    {
        return cstActivityMapper.updateCstActivity(cstActivity);
    }

    /**
     * 删除活动对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCstActivityByIds(String ids)
    {
        return cstActivityMapper.deleteCstActivityByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除活动信息
     * 
     * @param id 活动ID
     * @return 结果
     */
    @Override
    public int deleteCstActivityById(Integer id)
    {
        return cstActivityMapper.deleteCstActivityById(id);
    }

    @Override
    public int publishCstActivity(Integer id) {
        CstActivity cstActivity = cstActivityMapper.selectCstActivityById(id);
        if (cstActivity.getIsPublish()==0){
            cstActivity.setIsPublish(1);
        }else {
            cstActivity.setIsPublish(0);
        }
        return cstActivityMapper.updateCstActivity(cstActivity);
    }
}
